package com.wmcsk.dl.dl;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.wmcsk.dl.listener.Reciverable;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by admin on 2017/4/17.
 */
public class DLReceiver extends BroadcastReceiver {
    private static List<Reciverable> dlJpushReceiver;
    static {
        dlJpushReceiver = new ArrayList<>();
    }
    @Override
    public void onReceive(Context context, Intent intent) {
        if(dlJpushReceiver!=null){
            for(Reciverable reciverable:dlJpushReceiver){
                if(reciverable!=null){
                    reciverable.onReceive(context,intent);
                }
            }
        }
    }
    /**
     * 注册
     * @param reciverable
     */
    public static void registerReceiver(Reciverable reciverable){
        if(dlJpushReceiver!=null){
            if(reciverable!=null&&!dlJpushReceiver.contains(reciverable)){
                dlJpushReceiver.add(reciverable);
            }
        }
    }
    /**
     * 反注册
     * @param reciverable
     */
    public static void unRigisterReciver(Reciverable reciverable){
        if(dlJpushReceiver!=null){
            if(reciverable!=null&&dlJpushReceiver.contains(reciverable)){
                dlJpushReceiver.remove(reciverable);
            }
        }
    }
}
